package com.ellen.mac.chatdemo.comment;

import android.widget.ImageView;

import com.squareup.picasso.Picasso;
import com.yanzhenjie.album.AlbumFile;
import com.yanzhenjie.album.AlbumLoader;


/**
 * Created by j on 2017/12/15.
 */

public class PicassoImageLoader implements AlbumLoader {


    @Override
    public void loadAlbumFile(ImageView imageView, AlbumFile albumFile, int viewWidth, int viewHeight) {
        Picasso.with(imageView.getContext())
                .load("file://"+albumFile.getPath())
                .centerCrop()
                .resize(viewWidth, viewHeight)
                .into(imageView);
    }

    @Override
    public void loadImage(ImageView imageView, String imagePath, int viewWidth, int viewHeight) {
        if(imagePath.startsWith("http")){
            Picasso.with(imageView.getContext())
                    .load(imagePath)
                    .centerCrop()
                    .resize(viewWidth, viewHeight)
                    .into(imageView);
        }else{
            Picasso.with(imageView.getContext())
                    .load("file://"+imagePath)
                    .centerCrop()
                    .resize(viewWidth, viewHeight)
                    .into(imageView);
        }
    }
}